#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n;
int arr[N];
int help[N];
signed main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    // 我们的目标就是把help数组变为全0采用最小的操作数
    for (int i = 0; i < n / 2; i++)
    {
        help[i] = arr[i] - arr[n - 1 - i];
       // cout<<help[i]<<" ";
    }  
    //cout<<endl;
    // 每次先考虑同时加减如果相邻的同号可以进行操作跟新状态
    int ret = 0;
    // 因为从左往右枚举每个数因此相邻的话我们只考虑向右边
    for (int i = 0; i < n / 2;)
    {
        if(help[i]==0)
        {
            i++;
            continue;
        }
        int r=i+1;
        if(r<n/2)
        {
            if(help[i]*help[r]>0)
            {
                if(help[i]>0)
                {
                    int tem=min(help[i],help[r]);
                    help[i]-=tem;
                    help[r]-=tem;
                    ret+=tem;
                }
                else
                {
                    int tem=min(abs(help[i]),abs(help[r]));
                    help[i]+=tem;
                    help[r]+=tem;
                    ret+=tem;
                }
                if(help[i]==0) 
                {
                    i++;
                    continue;
                }
                else
                {
                    ret+=abs(help[i]);
                    help[i]=0;
                    i++;
                    continue;
                }
            }
            else
            {
                //两者异号
                ret+=abs(help[i]);
                help[i]=0;
                i++;
                continue;
            }
        }
        else
        {
            ret+=abs(help[i]);
            help[i]=0;
            i++;
            continue;
        }
    }
    cout<<ret<<endl;
    return 0;
}